package com.lanxiao.cloud.modules.dict.application;

import com.lanxiao.cloud.modules.dict.application.assembler.DictAssembler;
import com.lanxiao.cloud.modules.dict.application.dto.DictCmdAdd;
import com.lanxiao.cloud.modules.dict.application.dto.DictCmdUpdate;
import com.lanxiao.cloud.modules.dict.domain.service.IDictService;
import org.springframework.stereotype.Component;

/**
 * @author ：qiaoliang
 * @date ：2021-09-26
 */
@Component
public class DictCmdManager {

  private final IDictService dictService;
  private final DictAssembler dictAssembler;

  public DictCmdManager(IDictService dictService,
      DictAssembler dictAssembler) {
    this.dictService = dictService;
    this.dictAssembler = dictAssembler;
  }

  public void save(DictCmdAdd cmdAdd) {
    dictService.saveDict(dictAssembler.toDict(cmdAdd));
  }

  public void update(Long id, DictCmdUpdate cmdUpdate) {
    dictService.updateDict(dictAssembler.toDict(id, cmdUpdate));
  }

  public void delete(Long id) {
    dictService.deleteById(id);
  }

}
